package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.mapper.CmsPageTypeMapper;
import com.jic.manager.entity.CmsPageType;
import com.jic.manager.service.CmsPageTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 页面类型
 * @author : 
 * @email : 
 * @since : 2020-03-05 12:00:57
 * @version : v1.0.0
 */
@Service
public class CmsPageTypeServiceImpl implements CmsPageTypeService{

    @Autowired
    private CmsPageTypeMapper cmsPageTypeMapper;

    @Override
    public long insert(CmsPageType cmsPageType) {
        long flag = cmsPageTypeMapper.insert(cmsPageType);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return cmsPageTypeMapper.delete(id);
    }

    @Override
    public long update(CmsPageType cmsPageType) {
        return cmsPageTypeMapper.update(cmsPageType);
    }

    @Override
    public CmsPageType queryByPrimaryKey(Long id){
        return cmsPageTypeMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<CmsPageType> query(CmsPageType cmsPageType){
        return cmsPageTypeMapper.query(cmsPageType);
    }

    @Override
    public PageResult<CmsPageType> queryPage(CmsPageType cmsPageType, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<CmsPageType> list = cmsPageTypeMapper.queryPage(startIndex, pageQuery.getLimit(), cmsPageType);
        long count = cmsPageTypeMapper.queryPageCount(cmsPageType);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}